using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Blazor;
using Blazor.Services.AppSetting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

var httpClient = new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) };
builder.Services.AddScoped(sp => httpClient);

using var response = await httpClient.GetAsync("appsettings.json");
await using var stream = await response.Content.ReadAsStreamAsync();
builder.Configuration.AddJsonStream(stream);
builder.Configuration.AddInMemoryCollection(new List<KeyValuePair<string, string?>>
{
    new("TencentCloud:SecretId", "AKIDwkOq471jHexHSUPAlDWghaXLzTlusgKo"),
    new("TencentCloud:SecretKey", "UlsohQ2ZCPXSDnJepocGj185q5NAqPsD"),
});

var appSetting = new AppSetting(builder.Configuration);

builder.Services.AddSingleton(appSetting);
builder.Services.AddAntDesign();
builder.Services.AddLocalization();

builder.Logging.SetMinimumLevel(LogLevel.Information);

builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

await builder.Build().RunAsync();